/** The following trigger will populate the unit price of the discount item field
*      for selected prodcut. This is required for calculating the discount and for reporting 
*      the the total discount at the SPA level (parent of discount item)
*      
*      Author - Sayeed Faruqi
*      Company - Cognizant Technology Solutions
*      Client - Cisco (LinkSys)
*     
*      Last update - Oct 2009
* 
**/
trigger UpdateUnitPrice on DiscountItems__c (before insert, before update) {
    // We will simply pass the records to Apex Class all validations
    // and execptions will be handled in the Apex Class for code reusability
    // point of view
    
    try {
            DiscountItems__c[] disc = trigger.new;
            NAUnitPrice.getPrice(disc);
    } //end try 
    catch (system.DMLException e) {
            for (Integer j =0; j <e.getNumDML(); j++) {
                //list process exceptions
                system.debug ('Error encountered in NAUnitPrice Apex trigger ' + e.getDMLmessage(j));
            }// end for
     } // end catch 
} // end trigger